package com.clean.cleantotal.compores.device

import android.os.Bundle
import androidx.core.view.isVisible
import com.clean.cleantotal.R
import com.clean.cleantotal.base.BaseActivity
import com.clean.cleantotal.bean.DataUtils
import com.clean.cleantotal.bean.DeviceBean
import com.clean.cleantotal.bean.FunType
import com.clean.cleantotal.databinding.ActivityDeviceBinding
import com.clean.cleantotal.compores.result.ResultActivity
import com.clean.cleantotal.utils.Utils
import com.drake.brv.utils.linear
import com.drake.brv.utils.setup

class DeviceActivity : BaseActivity<ActivityDeviceBinding>() {
    override val viewBinding: ActivityDeviceBinding
        get() = ActivityDeviceBinding.inflate(layoutInflater)


    override fun initView() {
        mBinding.back.setOnClickListener { onBackPressed() }
        Utils.showScanDialog(this, FunType.DEVICE, mBinding.loadingLayout.scanLayout, {
            animal = it
        }) {

        }

        mBinding.includedLayout.tvTitle.text = "Android ${android.os.Build.VERSION.RELEASE}"
        mBinding.includedLayout.tvContent.text = "Hardware version"
        mBinding.includedLayout.fondYuan.isVisible = true

        mBinding.recyclerView1.linear().setup {
            addType<DeviceBean> { R.layout.item_device_layout }
        }.models = DataUtils.getDeviceList()
        mBinding.recyclerView2.linear().setup {
            addType<DeviceBean> { R.layout.item_device_layout }
        }.models = DataUtils.getWifiList(this)

        animal?.duration = 3000
        mBinding.okLayout.setOnClickListener {
            openActivity(ResultActivity::class.java, Bundle().apply {
                putSerializable("funType", FunType.DEVICE)
                finish()
            })
        }
    }

}